﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wdwp.Desktop.Launcher;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using wdwp.Desktop.widgetLib.Utils;
using wdwp.Desktop.widgetLib.CommonTypes;

namespace classTestProject
{
    class Program
    {
        static void Main(string[] args)
        {
            /* test code for widgetSrcManager class  */
              
            widgetSrcManager sm = new widgetSrcManager(".");
            
            sm.refresh();

            sWidgetInfo Info = (sWidgetInfo)sm.WidgetSrcList[0];

            //sm.unRegWidget(Info.Name);

            /* test code for widgetProcManager class  */

            //widgetProcManager pm = new widgetProcManager();
            
            //Process myProc = pm.runNewWidget(Info);

            //Console.WriteLine("Wait for certain sec..");
            //Console.ReadLine();

            //Console.WriteLine(" myProc.MainWindowHandle : {0} ", myProc.MainWindowHandle.ToString("X2"));            
                        
            //Console.WriteLine(" return from creator : {0} ", myProc.ToString());
                
            //Console.WriteLine(" return from killer : {0} ", pm.killRunWidget(Info));

            //IPC 테스트          

            Console.WriteLine("Wait for certain sec..");
            Console.ReadLine();


            /* test code for Serializer class  */
            Serializer myS = new Serializer();

            WidgetEventArgs testEvent1 = new WidgetEventArgs("test", "Serializer");

            Serializer.Serialize("testSer.data", testEvent1 as object);
 

            WidgetEventArgs testEvent2 = new WidgetEventArgs();
            Object testEventConv = testEvent2 as Object;

            Serializer.DeSerialize("testSer.data", ref testEventConv);

            testEvent2 = testEventConv as WidgetEventArgs;

            Console.WriteLine("MSG : " + (testEventConv as WidgetEventArgs).Msg);
            Console.WriteLine("SUBJECT : " + (testEventConv as WidgetEventArgs).Subject);

            Console.WriteLine("Wait for certain sec..");
            Console.ReadLine();

            Serializer.Serialize("testSer.xml", testEvent1, typeof(WidgetEventArgs), "WidgetEventArgs");

            Serializer.DeSerialize("testSer.xml", ref testEventConv, typeof(WidgetEventArgs), "WidgetEventArgs");

            Console.WriteLine("MSG : " + (testEventConv as WidgetEventArgs).Msg);
            Console.WriteLine("SUBJECT : " + (testEventConv as WidgetEventArgs).Subject);

            Console.WriteLine("Wait for certain sec..");
            Console.ReadLine();

        }

        
    }
}
